package com.xxa.controller;

import com.baomidou.mybatisplus.plugins.pagination.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxa.domain.PmsSpuInfo;
import com.xxa.service.PmsSpuInfoService;
import com.xxa.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class ProductionController {

    @Autowired
    private PmsSpuInfoService pmsSpuInfoService;

    @RequestMapping("/spuInfolist")
    public Result SpuInfo(){
        return Result.success(pmsSpuInfoService.list());
    }

    @RequestMapping("/spuInfopageList")
    public Result SpuInfopageList(Integer current,Integer size,@RequestBody PmsSpuInfo pmsSpuInfo){
        PageHelper.startPage(current,size);
        List<PmsSpuInfo> list=pmsSpuInfoService.selectList(pmsSpuInfo);
        return Result.success(new PageInfo<>(list));
    }

    @RequestMapping("/spuInfoadd")
    public Result add(@RequestBody PmsSpuInfo pmsSpuInfo){
        boolean save = pmsSpuInfoService.save(pmsSpuInfo);
        return save?Result.success(save):Result.fail("添加失败");
    }

    @RequestMapping("/del")
    public Result del(){
        return Result.fail();
    }
}